package com.xunfang.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xunfang.bean.Log;
import com.xunfang.bean.vo.PageVo;
import com.xunfang.mapper.LogMapper;
import com.xunfang.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yellow Docter
 * @date 2023 -11-13
 * @desc
 */
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;

    @Override
    public void saveLog(Log log) {
        logMapper.saveLog(log);
    }

    @Override
    public PageVo findLogs(Integer currentPage, Integer pageSize) {

        Page page = PageHelper.startPage(currentPage,pageSize).doSelectPage(()->{
            logMapper.findLogAll();
        });
        PageVo pageVo = new PageVo();
        pageVo.setTotal(page.getTotal());
        pageVo.setData(page.getResult());
        return pageVo;
    }

}
